package jgl.vajra.operator.part.mine.viewModel;

import com.orhanobut.logger.Logger;

import java.util.List;
import java.util.Map;

import jgl.vajra.operator.bean.CarDocumentTypeBean;
import jgl.vajra.operator.part.mine.contract.CarInformationContract;
import jgl.vajra.operator.part.mine.model.CarInformationModel;
import jgl.vajra.operator.widget.mvvm.factory.CreateModel;
import jgl.vajra.operator.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(CarInformationModel.class)
public class CarInformationViewModel  extends CarInformationContract.ViewModel{

    @Override
    public void getRandomOrderNumber() {
        mModel.getRandomOrderNumber().subscribe(new ProgressObserver<String>(false, null) {
            @Override
            public void _onNext(String randomOrderNumber) {
                mView.returnRandomOrderNumberSuccess(randomOrderNumber);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
                Logger.d("访问失败" + errorMessage);
            }
        });
    }

    @Override
    public void getCarDocumentTypeData(Map<String, Object> map) {
        mModel.getCarDocumentTypeData(map).subscribe(new ProgressObserver<List<CarDocumentTypeBean>>(false,null) {
            @Override
            public void _onNext(List<CarDocumentTypeBean> data) {
                mView.returnCarDocumentTypeData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }
}
